﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.OleDb;

namespace FormLib.Forms
{
    public partial class handleMethodForm : DevExpress.XtraEditors.XtraForm
    {
        public handleMethodForm()
        {
            InitializeComponent();
        }

        private void handleMethodForm_Load(object sender, EventArgs e)
        {
            
            string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\datasource.accdb";
            OleDbDataAdapter oda = new OleDbDataAdapter("select * from 应急处置方法", connString);
            DataSet ds = new DataSet();
            oda.Fill(ds);
            gridControl1.DataSource = ds.Tables[0];
            

        }
        DevExpress.XtraEditors.BaseEdit currentEditor = null;
        private void gridView1_ShownEditor(object sender, EventArgs e)
        {
            //Get the current editor
            currentEditor = (sender as DevExpress.XtraGrid.Views.Grid.GridView).ActiveEditor;
            //Subscribe to the DoubleClick event
            currentEditor.DoubleClick += new EventHandler(ActiveEditor_DoubleClick);
        }

        private void gridView1_HiddenEditor(object sender, EventArgs e)
        {
            if (currentEditor != null)
            {
                //Unsubscribe to the DoubleClick event
                currentEditor.DoubleClick -= ActiveEditor_DoubleClick;
                currentEditor.Dispose();
            }
        }

        private void ActiveEditor_DoubleClick(object sender, EventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo = gridView1.CalcHitInfo( this.gridControl1.PointToClient(Control.MousePosition));

            if (hitInfo.InRowCell == false)
            {
                return;
            }
            string temp = gridView1.FocusedValue.ToString();
            cellStringForm cf = new cellStringForm();
            cf.data = temp;
            cf.Show();
        }

        
    }
}